package com.lhx.mapper;

import com.lhx.pojo.User;
import org.apache.ibatis.annotations.*;
import org.springframework.boot.autoconfigure.security.SecurityProperties;

import java.util.List;

@Mapper// 这个注解表示这个接口被Spring管理了, Spring会自动创建这个接口的实现类, 这个实现类会自动注入到其他类中, Spring会自动注入这个实现类中的方法
public interface userMapper {

    @Select("select * from user")
    public List<User> findAll();

    @Delete("delete from user where id=#{id}")
    public Integer deleteById(Integer id);

    @Insert("insert into user(username,password,name,age) values(#{username},#{password},#{name},#{age})")
    public Integer insert(User user);

    @Update("update user set username=#{username},password=#{password},name=#{name},age=#{age} where id=#{id}")
    public Integer update(User user);

    @Select("select * from user where username=#{a} and password=#{b}")
    public User findByUsernameAndPassword(@Param("a") String b, @Param("b") String a);


}
